package org.jeecg.modules.business.mapper;

import java.math.BigDecimal;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.poi.hpsf.Decimal;
import org.jeecg.modules.business.entity.BusMarketCouponsCashUsed;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.business.entity.BusMarketMealCouponsUsed;

/**
 * @Description: bus_market_coupons_cash_used
 * @Author: jeecg-boot
 * @Date:   2023-03-11
 * @Version: V1.0
 */
public interface BusMarketCouponsCashUsedMapper extends BaseMapper<BusMarketCouponsCashUsed> {

    /**
     * 获取可用优惠券
     * @param page
     * @param hotelId
     * @param conditions 满多少金额
     * @param mobile 手机号
     * @return
     */
    @Select("<script>select coupons_cash_used.id,coupons_cash.name as couponsName,coupons_cash.cost from bus_market_coupons_cash_used coupons_cash_used " +
            "inner join bus_market_coupons_cash_info coupons_cash\n" +
            "on coupons_cash.id=coupons_cash_used.coupons_id\n" +
            "where coupons_cash_used.status=1\n" +
            "<if test='mobile != null and mobile !=\"\"'> and coupons_cash_used.userId = #{mobile} </if>"+
            "<if test='hotelId != null and hotelId !=\"\"'> and coupons_cash_used.hotel_id = #{hotelId} </if>"+
            "<if test='conditions >0'> and (coupons_cash.type=1 or (coupons_cash.type=2 and coupons_cash.conditions>=#{conditions}))</if>"+
            "</script>")
    public List<BusMarketMealCouponsUsed> memeberCouponList(Page<BusMarketMealCouponsUsed> page, String hotelId, BigDecimal conditions, String mobile);
}
